/* 递推和递归
* 1.约数之和定理
    N = p1^a1 * p2^a2 * p3^a3 * p4^a4 * ... * pk^ak
    约数个数 = (a1+1)*(a2+2)*(a3+3)*...*(ak+1)
    约数之和 = (1+p1+p1^2+...+p^a1)*(1+p2+p2^2+...+p2^a2)*...*(1+pk+pk^2+...+pk^ak)
    等比数列前缀和: Sn = p^0+p^1+...+p^(k-1) = (p^k-1)/(p-1)

    1.k是偶数
        sum(p, k) = p^0+p^1+...+p^(k/2-1)+p^(k/2)+...+p^(k-1)
                  = sum(p, k/2)+p^(k/2)*sum(p, k/2)
                  = (1+p^(k/2))*sum(p, k/2)
    2.k是奇数
        sum(p, k) = p^0+p^1+...+p^(k-1)
                  = p^0+p*(p^0+p^1+...+p^(k-2))
                  = 1 + p * sum(p, k-1)
* 本题:
    分块处理
    从N处理到N-1一次向下递归，拿到实际位置在向上递归出之前有多少大块
*/
#define DEBUG
#pragma GCC optimize("O1,O2,O3,Ofast")
#pragma GCC optimize("no-stack-protector,unroll-loops,fast-math,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,ssse3")

#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
#define int long long
using Point = pair<int, int>;
#define x first
#define y second

Point get(int n, int a) //等级 坐标(从0开始)
{
    if(n == 0) return {0, 0};
    int block = 1ll << n*2 -2, len = 1ll << n-1; //单象限容量 单象限边长
    auto p = get(n-1, a%block); //递归信息
    int x = p.x, y = p.y;
    auto z = a / block; //递归出的块属于当前等级的哪个象限
    if(z == 0) return {y, x}; //左上
    else if(z==1) return {x, y+len}; //右上
    else if(z==2) return {x+len, y+len}; //右下
    else return {2*len-1-y, len-1-x}; //左下 block从0开始计
}

signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
    #else
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #endif
    
    int T; cin >> T;
    while(T--) {
        int n, a, b; cin >> n >> a >> b;
        auto pa = get(n, a-1);
        auto pb = get(n, b-1);
        double dx = pa.x - pb.x, dy = pa.y - pb.y;
        printf("%.0lf\n", sqrt(dx*dx + dy*dy) * 10); //边长为10m的正方形
    }
    return 0;
}